#include "SpriteObject.h"

class Sprite::SpriteRtti
{
public:
	SpriteRtti(const wchar_t* strClassName,int iNumBaseClasses = 0,...)
	{
		m_strClassName = strClassName;
		assert(iNumBaseClasses>=0);
		if (iNumBaseClasses == 0)
		{
			m_uNumBaseClasses = 0;
			m_apCBassType = NULL;
		} 
		else
		{
			m_uNumBaseClasses = iNumBaseClasses;
			m_apCBassType = new SpriteRtti*[m_uNumBaseClasses];
			va_list list;
			va_start(list,m_uNumBaseClasses);
			for(int i = 0;i<iNumBaseClasses;i++)
			{
				m_apCBassType[i] = va_arg(list,SpriteRtti*);
			}
			va_end(list);
		}
	}
	~SpriteRtti()
	{
		delete[] m_apCBassType;
	}

	bool isDerived(const SpriteRtti& rCType)const
	{
		if (&rCType == this)
		{
			return true;
		}
		for (unsigned int i=0;i<m_uNumBaseClasses;i++)
		{
			if (m_apCBassType[i]->isDerived(rCType))
			{
				return true;
			}
		}
		return false;
	}
private:
	const wchar_t* m_strClassName;
	unsigned int m_uNumBaseClasses;
	SpriteRtti** m_apCBassType;
};

Sprite::SpriteObject::SpriteObject()
{
}
const  Sprite::SpriteRtti Sprite::SpriteObject::TYPE(L"Sprite.SpriteObject");